﻿namespace YidanSoft.Library.EditorUtility.WinControls
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Threading;
    using System.Windows.Forms;
    using YidanSoft.Library.EditorUtility.Collections;
    using YidanSoft.Library.EditorUtility.General;

    [ToolboxItem(false)]
    public class OutlookBarBand : Control
    {
        private Color background;
        private Control childControl;
        private YidanSoft.Library.EditorUtility.WinControls.IconView iconView;
        private OutlookBarIconViewChangedHandler IconViewChanged;
        private OutlookBarItemCollection items;
        private ImageList largeImageList;
        private ImageList smallImageList;
        private Color textColor;

        public event OutlookBarIconViewChangedHandler IconViewChanged
        {
            add
            {
                OutlookBarIconViewChangedHandler handler2;
                OutlookBarIconViewChangedHandler iconViewChanged = this.IconViewChanged;
                do
                {
                    handler2 = iconViewChanged;
                    OutlookBarIconViewChangedHandler handler3 = (OutlookBarIconViewChangedHandler) Delegate.Combine(handler2, value);
                    iconViewChanged = Interlocked.CompareExchange<OutlookBarIconViewChangedHandler>(ref this.IconViewChanged, handler3, handler2);
                }
                while (iconViewChanged != handler2);
            }
            remove
            {
                OutlookBarIconViewChangedHandler handler2;
                OutlookBarIconViewChangedHandler iconViewChanged = this.IconViewChanged;
                do
                {
                    handler2 = iconViewChanged;
                    OutlookBarIconViewChangedHandler handler3 = (OutlookBarIconViewChangedHandler) Delegate.Remove(handler2, value);
                    iconViewChanged = Interlocked.CompareExchange<OutlookBarIconViewChangedHandler>(ref this.IconViewChanged, handler3, handler2);
                }
                while (iconViewChanged != handler2);
            }
        }

        public OutlookBarBand()
        {
            this.childControl = null;
            this.smallImageList = null;
            this.largeImageList = null;
            this.items = null;
            this.background = ColorUtil.VSNetControlColor;
            this.textColor = SystemColors.ControlText;
            this.iconView = YidanSoft.Library.EditorUtility.WinControls.IconView.Large;
            this.items = new OutlookBarItemCollection();
            if (this.Site != null)
            {
                base.Name = this.Site.Name;
            }
            else
            {
                base.Name = null;
            }
        }

        public OutlookBarBand(string text)
        {
            this.childControl = null;
            this.smallImageList = null;
            this.largeImageList = null;
            this.items = null;
            this.background = ColorUtil.VSNetControlColor;
            this.textColor = SystemColors.ControlText;
            this.iconView = YidanSoft.Library.EditorUtility.WinControls.IconView.Large;
            this.Text = text;
            this.items = new OutlookBarItemCollection();
        }

        public OutlookBarBand(string text, Control childControl)
        {
            this.childControl = null;
            this.smallImageList = null;
            this.largeImageList = null;
            this.items = null;
            this.background = ColorUtil.VSNetControlColor;
            this.textColor = SystemColors.ControlText;
            this.iconView = YidanSoft.Library.EditorUtility.WinControls.IconView.Large;
            this.Text = text;
            this.childControl = childControl;
        }

        protected override void Dispose(bool disposing)
        {
            if (this.items != null)
            {
                this.items.Clear();
            }
            base.Dispose(disposing);
        }

        private void FireIconViewChanged()
        {
            if (this.IconViewChanged != null)
            {
                this.IconViewChanged(this);
            }
        }

        private void InitializeComponent()
        {
            base.SuspendLayout();
            this.AllowDrop = true;
            base.ResumeLayout(false);
        }

        public Color Background
        {
            get
            {
                return this.background;
            }
            set
            {
                this.background = value;
            }
        }

        public Control ChildControl
        {
            get
            {
                return this.childControl;
            }
        }

        public YidanSoft.Library.EditorUtility.WinControls.IconView IconView
        {
            get
            {
                return this.iconView;
            }
            set
            {
                this.iconView = value;
            }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public OutlookBarItemCollection Items
        {
            get
            {
                return this.items;
            }
        }

        public ImageList LargeImageList
        {
            get
            {
                return this.largeImageList;
            }
            set
            {
                this.largeImageList = value;
            }
        }

        public ImageList SmallImageList
        {
            get
            {
                return this.smallImageList;
            }
            set
            {
                this.smallImageList = value;
            }
        }

        public Color TextColor
        {
            get
            {
                return this.textColor;
            }
            set
            {
                this.textColor = value;
            }
        }
    }
}

